package com.tedu.controller;

import com.tedu.entity.Emp;
import com.tedu.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "EmpServlet",value = "/emp/findAllEmp")
public class EmpServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 获取请求参数

        // 调用业务逻辑
        EmpServiceImpl empService = new EmpServiceImpl();
        List<Emp> allEmp = empService.findAllEmp();

        // 请求跳转
        request.setAttribute("emps", allEmp);
        request.getRequestDispatcher("/ems/emp/emplist.jsp").
                forward(request, response);
    }
}
